/*
	Copyright (C) 2008 by Jean-François Geyelin
	jfgeyelin@gmail.com

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the
	Free Software Foundation, Inc.,
	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "Dezoomer.h"
#include "globals.h"

Dezoomer::Dezoomer(void):Object(0,0,1,1) {
    speed = 1;
    max = 3;
}

Dezoomer::~Dezoomer(void) {}

void Dezoomer::draw(void) {}

void Dezoomer::animate(void) {


    if (decrease) {
        zoomFactor-=speed*((float)(zoomFactor/400));
        if (zoomFactor<=1) {
            zoomFactor = 1;
            decrease = false;
            mustBeDestroyed = true;
        }
    }

    if (increase) {
        zoomFactor+=speed*((float)(zoomFactor/400));
        if (zoomFactor>=max) {
            zoomFactor = max;
            increase = false;
            mustBeDestroyed = true;
        }
    }
}

void Dezoomer::handleCollisionWithObject(Object *o) {}

void Dezoomer::setDirection(int d) {
    decrease = false;
    increase = false;
    if (d<0) {
        decrease = true;
    }
    if (d>0) {
        increase = true;
    }
}

void Dezoomer::setSpeed(float speed_) {
    speed = speed_;
}

void Dezoomer::setMax(int max_) {
    max = max_;
}
